package com.cxlin.cwanandroid.ui.home.adapter

import androidx.databinding.library.baseAdapters.BR
import com.cxlin.base.view.recyclerview.adapter.BaseAdapter
import com.cxlin.base.view.recyclerview.adapter.Handler
import com.cxlin.cwanandroid.R
import com.cxlin.cwanandroid.databinding.ItemArticleConstraintBinding
import com.cxlin.cwanandroid.model.bean.Article

/**
 *
 * @Author: chenxunlin
 * @Date: 2024/4/25 17:38
 */
class ArticleAdapter() :
    BaseAdapter<Article, ItemArticleConstraintBinding>(R.layout.item_article_constraint, BR.item) {


    override fun onBindViewHolder(
        holder: VH<ItemArticleConstraintBinding>,
        position: Int,
        item: Article?
    ) {
        super.onBindViewHolder(holder, position, item)
        item?.run {
            holder.binding.articleStar.setImageResource(
                if (collect)
                    R.drawable.timeline_like_pressed
                else
                    R.drawable.timeline_like_normal
            )
            holder.binding.articleAuthor.text =
                if (author.isBlank()) "分享者: ${item.shareUser}"
                else item.author
        }
    }


}